package com.sntk.organauthomanager.infrastructure.convert;

import com.sntk.organauthomanager.domain.model.Organization;
import com.sntk.organauthomanager.infrastructure.db.entity.OrganizationEntity;
import org.springframework.stereotype.Component;

/**
 * @ClassName: OrganizationConvert
 * @author: wgchao
 * @createTime: 2020/7/20 4:43 PM
 * @Description: TODO
 */
@Component
public class OrganizationConvert {
    public OrganizationEntity convert(Organization organization){
        OrganizationEntity entity = new OrganizationEntity();
        entity.setId(organization.getId());
        entity.setInstitutionNumber(organization.getInstitutionNumber());
        entity.setInstitutionName(organization.getInstitutionName());
        entity.setInstitutionalAddress(organization.getInstitutionalAddress());
        entity.setHisInstitutionNumber(organization.getHisInstitutionNumber());
        entity.setRemark(organization.getRemark());
        entity.setDisabled(organization.isDisabled());
        entity.setSuperiorNumber(organization.getSuperiorNumber());
        entity.setVersion(organization.getVersion());
        return entity;
    }

    public Organization convert(OrganizationEntity entity){
        return new Organization(entity.getId(), entity.getInstitutionNumber(), entity.getInstitutionName(),
                entity.getInstitutionalAddress(), entity.getHisInstitutionNumber(),
                entity.getRemark(), entity.getSuperiorNumber(), entity.isDisabled(),
                entity.getVersion());
    }
}
